
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Uploader</title>
<style type="text/css">
	p {
		font-family: "BankGothic Lt BT", Geneva;
		font-size: 24px;
		color: #FFF;
	}
	
	p1 {
		font-family: "BankGothic Lt BT", Geneva;
		font-size: 14px;
		color: #FFF;
	}
</style>
</head>

<body bgcolor="#000000">

<?php
include ("dbConfig.php");

$uploadType = $_POST['uploadType'];

if ($uploadType == Picture){
		$target_path = "uploads/pics/";
		$selectedTable = "UPLOADPICS";
	} 

	if ($uploadType == Video){
		$target_path = "uploads/videos/";
		$selectedTable = "UPLOADVIDS";
	} 

	if ($uploadType == Fact){
		$target_path = "uploads/facts/";
		$selectedTable = "UPLOADFACTS";
	} 

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
	?>
	<p> Your file has been uploaded!<p>
    <p1> Redirecting, please wait</p1>
    <script type="text/javascript">;
			window.location.href='http://manning3.jcu.edu.au/~jc192699/pics.php';
			</script>
	<?php
	try{
	$sql = "INSERT INTO ".$selectedTable." VALUES ('http://manning3.jcu.edu.au/~jc192699/".$target_path."')";
	
	$sth = $dbhandle->query($sql);
	}
	
	catch(PDOException $e) {
    	echo $e->getMessage();
	}
	
} else{
	?>
	<p>Error uploading file, please try again!</p>
    <p1> Redirecting, please wait</p1>
    <script type="text/javascript">;
			alert("Error uploading file, please try again!");
			history.back();
			</script>
	<?php
}



?>
</body>

</html>